<?php

namespace app\admin\controller;


use app\admin\common\Constants;
use think\Controller;
use think\Log;
use think\Queue;

class TestJob extends Controller
{
    public function index()
    {
        $params = ["id" => rand(1, 100)];
        //创建一个5秒后启动的定时任务
        $isPushed = Queue::later(5, Constants::$DELAY_QUEUE['handler'], $params, Constants::$DELAY_QUEUE['queue']);
        if ($isPushed !== false) {
            Log::info('定时任务推送成功:' . $isPushed);
        } else {
            Log::error('定时任务推送失败:' . $isPushed);
        }
    }
}